<?php global $ubi;?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>TÙM LUM site</title>
        
		<link href="include/css/style.css" media="screen" rel="stylesheet" type="text/css" />
		<link href="include/css/styles.css" type="text/css" media="all" rel="stylesheet" id="contact-form-7-css" />
        <link href="include/css/site.css" media="screen" type="text/css" rel="stylesheet" />
		
		<script language="javascript" src=include/script/jquery-1.4.4.min.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript" src="include/script/ajaxupload.3.5.js" ></script>
		
		<script type="text/javascript" language="javascript">
			$(document).ready(function(){
				$('#blockSignIn').load('index.php?load&view=blockSignIn');
				$('#blockSearch').load('index.php?load&view=blockSearch');
				$('#blockMembers').load('index.php?load&view=blockMembers');
				$('#blockNewestPosts').load('index.php?load&view=blockNewestPosts');
				$('#mainMenu').load('index.php?load&view=menu');
				$('#randomItemProvider').load('index.php?load&view=randomItemProvider');
				$('#footer').load('index.php?load&view=footer');

				$('a.frame_avatar.set_default').bind('click', function() {
					var id = $(this).parent().attr('id');
					$.post('index.php?send&type=defaultAvatar', 
							{id:id}, function(data){
								if (data == '1') {
									alert('Đặt avatar mặc định thành công');
									location.reload(true);		
								} else {
									alert('Có lỗi xảy ra, bạn hãy thử lại !!!');
								}			
							}
					);
				});	

				$('a.frame_avatar.delete').bind('click', function() {
					var ele = $(this).parent();
					var id = $(ele).attr('id');
					
					$.post('index.php?send&type=deleteAvatar', 
							{id:id}, function(data){
								if (data == '1') {
									$(ele).remove();		
								} else {
									alert('Có lỗi xảy ra, bạn hãy thử lại !!!');
								}			
							}
					);
				});

				var btnUpload=$('#btnUpload');
				var status=$('#status');
				
				new AjaxUpload(btnUpload, {
					action: 'index.php?send&type=avatar',
					name: 'avatar',
					onSubmit: function(file, ext){
						 if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
				            // extension is not allowed 
							status.text('Chỉ tập tin JPG, PNG hoặc GIF được phép upload');
							return false;
						}
						status.text('Đang upload...');
					},
					onComplete: function(file, response){					
						//On completion clear the status
						status.text('');
						//Add uploaded file to list
						if(response == '1'){
							location.reload(true);
						} else{
							alert('Có lỗi xảy ra. Bạn hãy thử lại', 'Upload hình');
						}
					}
				});
			});
		</script>
	</head>
    
    <body id="cookoffboard" class="home blog">
		<div id="corners">			
			<div class="header" id="main-head">
				<div id="hdr-info">
                	<div style="float:left">
                        <img id="logo" src="include/imgs/logo.png" alt="The Cook-Off Board" width="235px" />
                        <p id="desc">Tùm Lum, Tả Pí Lù, chia sẻ tất cả ở đây</p>
                    </div>
                    <div class="nav">
                        <div id="mainMenu"></div>
                        <div style="clear:both"></div>
                    </div>
				</div>               
			</div> <!--end header-->
            
			<div class="polaroids">
            	<div class="marginBoxPicCollection" id="randomItemProvider"></div>                                                                            
            </div> <!--end polaris-->
            
            <div id="container">
				<hr />
                <div class="left">
                    <div class="section" id="content">
                    	<div class="yd_rp_widget">
                    		<?php
                    			if ($avatars) {
	                    			foreach ($avatars as $avatar) {
							?>
							<div class="avatarFrame" id="<?php echo $avatar->getResourceID()?>">
                    			<img src="<?php echo $ubi['SERVER']['THUMBNAIL_PATH']?>/<?php echo $resources[$avatar->getResourceID()]->getResourceName()?>" class="exampleAvatar" 
                    				title="Ảnh đại diện" class="defaultIconAvatar" />
                    			<span class="defaultAvatar">	
                    			<?php
                    				if ($avatar->isDefault()) {
                    			?>
	                    				<img src="include/images/icons/star.png" 
	                    					title="Đây là avatar mặc định" />
                    			<?php 
                    				} 
                    			?>	
                    			</span>
                    			
                    			<?php
                    				if (!$avatar->isDefault()) {
                    			?>
                    			<a class="a_cursor frame_avatar set_default">
                    				<img src="include/images/icons/user-check.png" title="Đặt làm avatar chính" class="imgBtn" />
                    			</a>
                    			<?php
                    				} 
                    			?>
                    			
                    			<a class="a_cursor frame_avatar delete">
                    				<img src="include/images/icons/user-delete.png" title="Xóa avatar này" class="imgBtn" />
                    			</a>
                    		</div>
							<?php 
	                    			} 
                    			}
                    		?>                    	
                    		<hr />
                    		<div id="status"></div>
                    		<input type="button" name="imgResource" value="Upload thêm avatar" id="btnUpload" />
                    			
						</div>                                           
                    </div>  <!--end section -->
            	</div> <!-- end left -->        
                <div class="right">
        			<div class="aside">
                        <ul>	
                            <li class="blockRight" id="blockSignIn"></li>
                            <li class="blockRight" id="blockSearch"></li>                                            
                            <li class="blockRight" id="blockMembers"></li>
                            <li class="blockRight" id="blockNewestPosts"></li>                          
                        </ul>
                    </div>        
                </div> <!--end right-->
			</div> <!--end container-->		
            
           	<div id="footer" class="footer clearfix"></div>          
		</div>
	</body>
</html>